home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / BoxIn fade.c next >
Text File  |  1994-04-15  |  3KB  |  74 lines

  1. /**********************************************************************\
  2.  
  3. File:        BoxIn fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define CorrectTime 3
  30.  
  31. pascal short BoxInFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Basically, there are four bars -- one starts at the top and moves down;
  34.    one starts at the bottom and moves up; one starts at the left and moves
  35.    right; one starts at the right and moves left.  There's a lot of overlap
  36.    of bitcopying, but it's masked by the timing correction */
  37.    
  38. pascal short BoxInFade(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     Rect        vsource1,vsource2, hsource1, hsource2;
  41.     int            vbar,hbar;
  42.     int            HBarGap,VBarGap;
  43.     
  44.     VBarGap=theWindowWidth/50;
  45.     HBarGap=theWindowHeight/50;
  46.     vbar=boundsRect.left;
  47.     hbar=boundsRect.top;
  48.     vsource1.top=vsource2.top=boundsRect.top;
  49.     vsource1.bottom=vsource2.bottom=boundsRect.bottom;
  50.     hsource1.left=hsource2.left=boundsRect.left;
  51.     hsource1.right=hsource2.right=boundsRect.right;
  52.     while (vbar<boundsRect.left+theWindowWidth/2+VBarGap)
  53.     {
  54.         StartTiming();
  55.         vsource1.left=vbar;
  56.         vsource1.right=vsource1.left+VBarGap;
  57.         vsource2.right=2*boundsRect.left+theWindowWidth-vbar;
  58.         vsource2.left=vsource2.right-VBarGap;
  59.         hsource1.top=hbar;
  60.         hsource1.bottom=hsource1.top+HBarGap;
  61.         hsource2.bottom=2*boundsRect.top+theWindowHeight-hbar;
  62.         hsource2.top=hsource2.bottom-HBarGap;
  63.         FillRect(&vsource1, *thePattern);
  64.         FillRect(&hsource1, *thePattern);
  65.         FillRect(&vsource2, *thePattern);
  66.         FillRect(&hsource2, *thePattern);
  67.         vbar+=VBarGap;
  68.         hbar+=HBarGap;
  69.         TimeCorrection(CorrectTime);
  70.     }
  71.     
  72.     return 0;
  73. }
  74.